<?php
namespace app\index\controller;

use think\Db;
use think\Request;

class App
{
    // 入口
	public function index()
	{
		return ['data'=>'欢迎来到api.vchao.top','code'=>1,'message'=>'操作完成'];
	}

    // 获取版本信息
     public function getNewVersion()
     {
     	$request = Request::instance();

     	$res = Db::table('version')
     	->limit(1)
     	->select();


     	if ($res) {
     		if (count($res) == 0) {
     			return ['code'=>2,'message'=>'no new version','data'=>$res];
     		}else{
     			$data = ['version_code' => reset($res)['version_code'],
     			'version_desc' => reset($res)['version_desc'],
     			'version_name' => reset($res)['version_name'],
     			'version_time' =>reset($res)['version_time'],
     			'version_url' => reset($res)['version_url']
     		];

     			return ['code'=>1,'message'=>'successful','data'=>$data];
     		}
     	}else{
     		return ['code'=>2,'message'=>'failed','data'=>$res];
     	}

     }

 }